home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Devil's Cubes 1.0.1 / source / Devil’s Cubes ƒ / Cube code / cube graphics.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  5.6 KB  |  306 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        cube graphics.c
  4.  
  5. Purpose:    This module handles actually drawing the board to an
  6.             offscreen bitmap; also drawing individual cubes.
  7.  
  8.  
  9. Devil’s Cubes -- a simple cubes puzzle
  10. Copyright (C) 1993 Mark Pilgrim
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "cube graphics.h"
  30. #include "cube.h"
  31. #include "msg graphics.h"
  32.  
  33. void DrawBoardColor(void)
  34. {
  35.     RGBColor    oldForeColor, oldBackColor;
  36.     GrafPtr        curPort;
  37.     Rect        space,dest;
  38.     RgnHandle    myRegion;
  39.     int            i,j;
  40.     int            x,y;
  41.     
  42.     GetForeColor(&oldForeColor);
  43.     GetBackColor(&oldBackColor);
  44.     
  45.     GetPort(&curPort);
  46.     
  47.     EraseRect(&(curPort->portRect));
  48.     
  49.     space.left=(gWindowWidth/2)-181;
  50.     space.right=space.left+359;
  51.     space.bottom=gWindowHeight-5;
  52.     space.top=space.bottom-57;
  53.     DrawPicture(gKeyPic,&space);
  54.  
  55.     space.left=(gWindowWidth/2)-219;
  56.     space.right=space.left+437;
  57.     space.top=5;
  58.     space.bottom=space.top+137;
  59.     if (gUseMirror)
  60.         DrawPicture(gCleanMirror, &space);
  61.     
  62.     for (i=0; i<4; i++)
  63.         DrawCubeColor(i);
  64.  
  65.     RGBForeColor(&oldForeColor);
  66.     RGBBackColor(&oldBackColor);
  67. }
  68.  
  69. void DrawBoardBW(void)
  70. {
  71.     GrafPtr        curPort;
  72.     Rect        space;
  73.     int            i;
  74.     
  75.     GetPort(&curPort);
  76.     
  77.     EraseRect(&(curPort->portRect));
  78.     
  79.     space.left=(gWindowWidth/2)-181;
  80.     space.right=space.left+359;
  81.     space.bottom=gWindowHeight-5;
  82.     space.top=space.bottom-57;
  83.     DrawPicture(gKeyPic,&space);
  84.  
  85.     space.left=(gWindowWidth/2)-219;
  86.     space.right=space.left+437;
  87.     space.top=5;
  88.     space.bottom=space.top+137;
  89.     if (gUseMirror)
  90.         DrawPicture(gCleanMirror, &space);
  91.     
  92.     for (i=0; i<4; i++)
  93.         DrawCubeBW(i);
  94. }
  95.  
  96. void DrawCubeColor(int i)
  97. {
  98.     int            x,y;
  99.     RgnHandle    myRegion;
  100.     
  101.     y=73;
  102.     x=(gWindowWidth/2)-152+100*i;
  103.     
  104.     myRegion=NewRgn();
  105.     
  106.     SetEmptyRgn(myRegion);
  107.     MoveTo(x,y);
  108.     OpenRgn();
  109.         Line(34,20);
  110.         Line(-34,20);
  111.         Line(-34,-20);
  112.         Line(34,-20);
  113.     CloseRgn(myRegion);
  114.     FillCRgn(myRegion, gColorPatterns[Cube[i][3]]);
  115.     
  116.     SetEmptyRgn(myRegion);
  117.     MoveTo(x,y);
  118.     OpenRgn();
  119.         Line(0,-40);
  120.         Line(-34,20);
  121.         Line(0,40);
  122.         Line(34,-20);
  123.     CloseRgn(myRegion);
  124.     if (gShowAll)
  125.         FillCRgn(myRegion, gColorPatterns[Cube[i][4]]);
  126.     else
  127.         FillRgn(myRegion, black);
  128.         
  129.     SetEmptyRgn(myRegion);
  130.     MoveTo(x,y);
  131.     OpenRgn();
  132.         Line(0,-40);
  133.         Line(34,20);
  134.         Line(0,40);
  135.         Line(-34,-20);
  136.     CloseRgn(myRegion);
  137.     FillCRgn(myRegion, gColorPatterns[Cube[i][0]]);
  138.     
  139.     MoveTo(x,y);
  140.     Line(0,-40);
  141.     Line(-34,20);
  142.     Line(0,40);
  143.     Line(34,-20);
  144.     Line(34,20);
  145.     Line(0,-40);
  146.     Line(-34,-20);
  147.     MoveTo(x+34,y+20);
  148.     Line(-34,20);
  149.     Line(-34,-20);
  150.     
  151.     y+=115;
  152.     
  153.     SetEmptyRgn(myRegion);
  154.     MoveTo(x,y);
  155.     OpenRgn();
  156.         Line(-34,-20);
  157.         Line(34,-20);
  158.         Line(34,20);
  159.         Line(-34,20);
  160.     CloseRgn(myRegion);
  161.     FillCRgn(myRegion, gColorPatterns[Cube[i][1]]);
  162.     
  163.     SetEmptyRgn(myRegion);
  164.     MoveTo(x,y);
  165.     OpenRgn();
  166.         Line(-34,-20);
  167.         Line(0,40);
  168.         Line(34,20);
  169.         Line(0,-40);
  170.     CloseRgn(myRegion);
  171.     FillCRgn(myRegion, gColorPatterns[Cube[i][2]]);
  172.     
  173.     SetEmptyRgn(myRegion);
  174.     MoveTo(x,y);
  175.     OpenRgn();
  176.         Line(34,-20);
  177.         Line(0,40);
  178.         Line(-34,20);
  179.         Line(0,-40);
  180.     CloseRgn(myRegion);
  181.     if (gShowAll)
  182.         FillCRgn(myRegion, gColorPatterns[Cube[i][5]]);
  183.     else
  184.         FillRgn(myRegion, black);
  185.         
  186.     MoveTo(x,y);
  187.     Line(-34,-20);
  188.     Line(0,40);
  189.     Line(34,20);
  190.     Line(0,-40);
  191.     Line(34,-20);
  192.     Line(0,40);
  193.     Line(-34,20);
  194.     MoveTo(x-34,y-20);
  195.     Line(34,-20);
  196.     Line(34,20);
  197.     
  198.     DisposeRgn(myRegion);
  199. }
  200.  
  201. void DrawCubeBW(int i)
  202. {
  203.     int            x,y;
  204.     RgnHandle    myRegion;
  205.     
  206.     y=73;
  207.     x=(gWindowWidth/2)-152+100*i;
  208.     
  209.     myRegion=NewRgn();
  210.     
  211.     SetEmptyRgn(myRegion);
  212.     MoveTo(x,y);
  213.     OpenRgn();
  214.         Line(34,20);
  215.         Line(-34,20);
  216.         Line(-34,-20);
  217.         Line(34,-20);
  218.     CloseRgn(myRegion);
  219.     FillRgn(myRegion, *gBWPatterns[Cube[i][3]]);
  220.     
  221.     SetEmptyRgn(myRegion);
  222.     MoveTo(x,y);
  223.     OpenRgn();
  224.         Line(0,-40);
  225.         Line(-34,20);
  226.         Line(0,40);
  227.         Line(34,-20);
  228.     CloseRgn(myRegion);
  229.     if (gShowAll)
  230.         FillRgn(myRegion, *gBWPatterns[Cube[i][4]]);
  231.     else
  232.         FillRgn(myRegion, black);
  233.         
  234.     SetEmptyRgn(myRegion);
  235.     MoveTo(x,y);
  236.     OpenRgn();
  237.         Line(0,-40);
  238.         Line(34,20);
  239.         Line(0,40);
  240.         Line(-34,-20);
  241.     CloseRgn(myRegion);
  242.     FillRgn(myRegion, *gBWPatterns[Cube[i][0]]);
  243.     
  244.     MoveTo(x,y);
  245.     Line(0,-40);
  246.     Line(-34,20);
  247.     Line(0,40);
  248.     Line(34,-20);
  249.     Line(34,20);
  250.     Line(0,-40);
  251.     Line(-34,-20);
  252.     MoveTo(x+34,y+20);
  253.     Line(-34,20);
  254.     Line(-34,-20);
  255.     
  256.     y+=115;
  257.     
  258.     SetEmptyRgn(myRegion);
  259.     MoveTo(x,y);
  260.     OpenRgn();
  261.         Line(-34,-20);
  262.         Line(34,-20);
  263.         Line(34,20);
  264.         Line(-34,20);
  265.     CloseRgn(myRegion);
  266.     FillRgn(myRegion, *gBWPatterns[Cube[i][1]]);
  267.     
  268.     SetEmptyRgn(myRegion);
  269.     MoveTo(x,y);
  270.     OpenRgn();
  271.         Line(-34,-20);
  272.         Line(0,40);
  273.         Line(34,20);
  274.         Line(0,-40);
  275.     CloseRgn(myRegion);
  276.     FillRgn(myRegion, *gBWPatterns[Cube[i][2]]);
  277.     
  278.     SetEmptyRgn(myRegion);
  279.     MoveTo(x,y);
  280.     OpenRgn();
  281.         Line(34,-20);
  282.         Line(0,40);
  283.         Line(-34,20);
  284.         Line(0,-40);
  285.     CloseRgn(myRegion);
  286.     if (gShowAll)
  287.         FillRgn(myRegion, *gBWPatterns[Cube[i][5]]);
  288.     else
  289.         FillRgn(myRegion, black);
  290.         
  291.     MoveTo(x,y);
  292.     Line(-34,-20);
  293.     Line(0,40);
  294.     Line(34,20);
  295.     Line(0,-40);
  296.     Line(34,-20);
  297.     Line(0,40);
  298.     Line(-34,20);
  299.     MoveTo(x-34,y-20);
  300.     Line(34,-20);
  301.     Line(34,20);
  302.     
  303.     DisposeRgn(myRegion);
  304.  
  305. }
  306.